{% extends "survey/base.html" %}
{% load i18n %}
{% load survey %}
{% block styles %}
<style type="text/css">
input[type="radio"] { vertical-align: top; }
</style>
{% endblock %}
{% block content %}
<h1>{{ survey.title }}</h1>
<ul class="object-tools"><li><a href='{% url survey-detail survey_slug=survey.slug %}' class="addlink">{% trans "View Online" %}</a></li></ul>
<table style="width: 100%">
    <thead>
        <th>{% trans "Object type" %}</th><th>{% trans "order" %}</th><th>{% trans "type" %}</th>
        <th>{% trans "Object" %}</th><th>{% trans "Actions" %}</th>
    </thead>
    <tr class="{% cycle row1,row2 %}">
        <td>{% trans "Survey"  %}</td>
        <td>-</td>
        <td>-</td>
        <td>

            <p> {{ survey.description }}</p>
            <p> {{ survey.opens }}</p>
            <p> {{ survey.closes }}</p>
        </td>
        <td>
            <a href='{% url survey-update survey_slug=survey.slug %}'>{% trans "Update"  %}</a>
            <a href='{% url survey-delete survey_slug=survey.slug %}'>{% trans "Delete"  %}</a>
            <a href='{% url question-add survey_slug=survey.slug %}'>{% trans "Add a question"  %}</a>
        </td>
    </tr>
    {% for question in survey.questions.all|order_by:"order" %}
        <tr>
            <td>{% trans "Question"  %}</td>
            <td>{{ question.order }}</td>
            <td>{{ question.get_qtype_display }}</td>
            <td>
                <p>{{ question.text }}</p>
                <p>{{ question.qstyle }}</p>
            </td>
            <td>
                <a href='{% url question-update survey_slug=survey.slug, question_id=question.id %}'>{% trans "Update"  %}</a>
                <a href='{% url question-delete survey_slug=survey.slug, question_id=question.id %}'>{% trans "Delete"  %}</a>
                <a href='{% url choice-add question_id=question.id %}'>{% trans "Add a choice"  %}</a>
            </td>
        </tr>
        {% for choice in question.choices.all|order_by:"order" %}
            <tr>
                <td>{% trans "choice"  %}</td>
                <td>{{ choice.order }}</td>
                <td>-</td>
                <td>
                    <p>{{ choice.text }}</p>
                </td>
                <td>
                    <a href='{% url choice-update question_id=question.id,choice_id=choice.id %}'>{% trans "Update"  %}</a>
                    <a href='{% url choice-delete survey_slug=survey.slug, choice_id=choice.id %}'>{% trans "Delete"  %}</a>
                </td>
            </tr>
        {% endfor %}
    {% endfor %}

</table>

{% endblock %}
